<template>
    <layout title="用户列换" :showBack="false" selected="me" :showTabBar="true">
        <group title="切换登录">
            <cell v-for="p in persons" :title="p.name" value="用该账号登录" :is-link="true" @click.native="login(p)"></cell>
        </group>
    </layout>
</template>

<script>
    import { Group, Datetime, XInput, FormPreview, XButton, Cell } from 'vux'
    import Layout from './Layout.vue'
    import { user as api } from '../api'
    import { cookie } from 'vux'

    export default {
        name: 'me',
        components: {
            Group,
            Datetime,
            XInput,
            FormPreview,
            XButton,
            Layout,
            Cell
        },
        data() {
            return {
                persons: []
            }
        },
        methods: {
            async login(user) {
                this.$router.push({ path: '/login', query: { userid: user.userid } })
            }
        },
        async mounted() {
            this.$store.commit('selectedTab', 'test')
            //获取人员列表
            let result = await api.list()
            this.persons = result.data.rows
        }
    }

</script>
